<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改密码</title>
<link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css"></link>
<link rel="stylesheet" type="text/css" href="../ext/resources/css/xtheme-slate.css"></link>
<script src="../ext/adapter/ext/ext-base.js"></script>
<script src="../ext/ext-all.js"></script>
<script src="../ext/src/locale/ext-lang-zh_CN.js"></script>	
<script src="../js/md5.js"></script>	
<script type="text/javascript">
			Ext.onReady(function(){
				Ext.Ajax.on('requestcomplete',checkUserSessionStatus, this);      
				function checkUserSessionStatus(conn,response,options){      
				    if(response.getResponseHeader('sessionstatus')){      
				    	parent.location.href='/xdj/index.jsp';   
				    }      
				}  
				Ext.BLANK_IMAGE_URL='ext/resources/images/default/s.gif';
				Ext.QuickTips.init();
				Ext.form.Field.prototype.msgTarget='side'; 
				//多字段验证用VType
				Ext.apply(Ext.form.VTypes,{
					password:function(val,field){
						if(field.initialPassField){
							
							var pwd = Ext.getCmp(field.initialPassField);
							return (val == pwd.getValue());
						}
						return true;
					},
					passwordText:'两次密码不一致'
				});
				
				var form=new Ext.form.FormPanel({
					id:'loginId',
					frame:true,
					baseCls:'header', //不设置该值，表单将保持原样，设置后表单与窗体完全融合 
					buttonAlign:'center',
					//labelAlign:'right',
					layout:'form', 
					labelWidth:80,
					defaultType:'textfield',
					defaults:{width:150,allowBlank:false,msgTarget:'side',
						 minLength:6,
						 minLengthText:'密码不能少于6位',
						 maxLength:10,
						 maxLengthText:'密码不能超过10位'},
					items:[{
						fieldLabel:'输入新密码',
						name:'password',
						//xtype:'textfield',
						inputType:'password',
						allowBlank:false,
						blankText:'密码不能为空',
						id:'password'
					},{
						fieldLabel:'再次输入密码',
						name:'secondPassword',
						//xtype:'textfield',  
						inputType:'password',
						vtype:'password',
						initialPassField:'password'	
					}],
					buttons:[{
				    	text: "修改密码",
				    	handler:function(){
							if(!form.getForm().isValid()){
				  		 	  return;
				  		   	};
				  		  Ext.Ajax.request({
								url:'../base/user_updatePwd',
								success:function(response){
									var result = Ext.util.JSON.decode(response.responseText);
									if(result.success==true){
										Ext.Msg.alert('','修改成功');
									}else{
										Ext.Msg.alert('','修改失败');
									}
								},failure:function(response){ 
			 						Ext.Msg.alert('','修改失败');
			 					},
								params:{password:encode(Ext.getCmp("password").getValue())}
							});
				  		/*form.getForm().submit({
								url:'../base/user_updatePwd',
								success:function(f,action){
									if(action.result.success){
										Ext.Msg.alert('','修改成功');
										form.getForm().reset();
									}
								},
								failure:function(f,action){ 
									form.getForm().reset();
			 						Ext.Msg.alert('','修改失败');
			 					} 
							});*/
						}
				     },{
				            text: "重置",
				            handler:function(){
				            	form.getForm().reset();
					           	Ext.getBody().unmask();
				               }
				        },{	hidden:true,
							
							width:70
							
						}]
				});
				var w= new Ext.Window({  
					 title:'修改密码',
					 width:400,
					 x:300,
					 y:90,
					// autoHeight:true,
					 height:150,
					 layout:'fit',
					 items:[form],
					 modal:true, //遮罩效果
					maxmizable:true, //最大化
					manimizable:true,//最小化 需要用函数去监听使用
					resizable:false,//不可改变大小的
					closeAction:'hide',//只有俩种方式  hide或close .close为一旦关闭就无法恢复，而hide为隐藏
					plain:true,//  整齐些 效果不明显 再试试
					constrain:true,//保证窗口在有效的浏览器之内 不超出
					constrainHeader:true,//保证窗口的顶部不超出 只有与constrain连用才好用
					draggable:false,//不可拖拽
					listeners:{
							'minimize':function(win){
								win.minimized=true;
								win.hide();
							}
						}
					});
					w.show();
			});
		</script> 
</head>
<body>

</body>
</html>